home *** CD-ROM | disk | FTP | other *** search
- /*================================================================================
- stringUtilities.h
-
- Greg Anderson
- 28 June 1991
- greggor@apple.com
-
- This .h file provides macros for scanning through strings.
- It is assumed that all strings being scanned are null-terminated
-
- ================================================================================*/
- #ifndef __STRINGUTILITIES__
- #define __STRINGUTILITIES__
-
- #ifndef __TYPES__
- #include <Types.h>
- #endif
-
- /*
- // Macros:
- //
- // ToUpper(c)
- //
- // Convert 'c' to an uppercase character if it is a lowercase character
- //
- // SkipToWhiteSpace(p)
- //
- // Skip to the next whitespace character (or null)
- //
- // SkipPastWhitespace(p)
- //
- // Skip to the next non-whitespace character (or null)
- //
- // SkipToSpec(p,spec)
- //
- // Skip to the next occurance of the specified character (or null)
- //
- // SkipToDigit(p)
- //
- // Skip to the next numeric digit (or null)
- //
- // SkipToNextLine(p)
- //
- // Like it says: skip to the beginning of the next line
- */
- #define ToUpper(c) ( ((c >= 'a') && (c <= 'z')) ? c - 'a' + 'A' : c )
- #define SkipToWhitespace( line ) while( *(line) > ' ' ) (line)++
- #define SkipPastWhitespace( line ) while( (*(line) <= ' ') && (*(line) != '\r') && (*(line)) ) (line)++
- #define SkipToSpec( line, spec ) while( (*(line) != spec) && (*(line)) ) (line)++
- #define SkipToDigit( line ) while( ((*(line) < '0') || (*(line) > '9')) && (*(line)) ) (line)++
- #define SkipToNextLine( line ) do{ SkipToSpec(line, '\r'); while( (*(line) < ' ') && (*(line)) ) (line)++; } while(false)
-
- /*
- // Prototypes for stringUtilities.c
- */
- pascal void PtoCcpy( char* cstr, Str255 pstr );
- pascal void CtoPcpy( Str255 pstr, char* cstr );
- pascal short PtoCcmp( Str255 pstr, char* cstr );
- pascal void pstrcpy( Str255 dest, Str255 src );
- pascal void pstrcat( Str255 dest, Str255 src );
- pascal short pstrcmp( unsigned char* a, unsigned char* b );
- pascal short partialstrcmp( register char* s1, register char* s2);
- pascal short ScanNumberInString( char** line );
- pascal short NumberInString( char* line );
- pascal void ScanTextInString( char** line, Str255 pstr, Boolean terminateAtSpace );
- pascal void ScanWordInString( char** line, Str255 pstr );
- pascal void ScanLineInString( char** line, Str255 pstr );
-
- #endif
-